package pit.com.ordermobilesystem;

import pit.com.ordermobilesystem.sharepreference.OrderSharePreference;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

public class SettingActivity extends BaseFragmentActivity{
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.activity_setting);

	        final EditText ed_host=(EditText) findViewById(R.id.ed_host);
	        ed_host.setText(OrderSharePreference.getHost(getApplicationContext()));
	        final EditText ed_port=(EditText) findViewById(R.id.ed_port);
	        ed_port.setText(OrderSharePreference.getPort(getApplicationContext()));
	        TextView tv_save=(TextView) findViewById(R.id.tv_save);
	        tv_save.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				OrderSharePreference.setHost(getApplicationContext(), ed_host.getText().toString());
				OrderSharePreference.setPort(getApplicationContext(), ed_port.getText().toString());
				showAlert("Save Setting", "Save successfully");
			}
		});
		getActionBar().setDisplayHomeAsUpEnabled(true);
	    }
		@Override
		public boolean onOptionsItemSelected(MenuItem item) {
		    switch (item.getItemId()) {
		    // Respond to the action bar's Up/Home button
		    case android.R.id.home:
		        //NavUtils.navigateUpFromSameTask(this);
			    finish();
		        return true;
		    }
		    return super.onOptionsItemSelected(item);
		}
}
